const int BUTTON_UP_PIN = 4;    // 亮度增加按键
const int BUTTON_DOWN_PIN = 5;  // 亮度减少按键
const int LED_PIN = 3;          // PWM输出引脚
const int MAX_BRIGHTNESS = 100 + 92;  //学号后两位为92

int brightness = 10;

void setup() {
  pinMode(BUTTON_UP_PIN, INPUT_PULLUP);
  pinMode(BUTTON_DOWN_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);
  analogWrite(LED_PIN, 10);  // 初始化为10亮度
}

void loop() {
  bool upPressed = digitalRead(BUTTON_UP_PIN) == LOW;
  bool downPressed = digitalRead(BUTTON_DOWN_PIN) == LOW;

  if (upPressed && brightness < MAX_BRIGHTNESS) 
  {
    brightness += 10;
  } 
  else if (downPressed && brightness > 0) 
  {
    brightness -= 10;
  }
    analogWrite(LED_PIN, brightness);

    delay(200);
}
